<?php


namespace frontend\models;
use yii\base\Model;
use yii\db\ActiveRecord;
use Yii;
class User extends ActiveRecord
{
    public static function tableName()
    {
        return '{{user}}';
    }
/*
 * 根据用户session获取用户id
 * */
    public static  function getUserId(){
        $session = Yii::$app->session;
        $user_name=$session->get('user');
        $user_id=self::find()
            ->where(['username' => $user_name])
            ->one()->id;
        return $user_id;
    }
}